package io.tec.cloud.algorithm.c03_v20220607;

import java.util.Stack;

public class Code05_GetMinStack {

    public static class MyStack1 {
        Stack<Integer> data;
        Stack<Integer> help;

        public MyStack1() {
            this.data = new Stack<>();
            this.help = new Stack<>();
        }

        public boolean push(Integer d) {
            if (help.isEmpty()) {
                help.push(d);
            } else {
                help.push(Math.min(d, getmin()));
            }
            data.push(d);
            return true;
        }

        public Integer pop() {
            help.pop();
            return data.pop();

        }

        public Integer getmin() {
            return help.peek();
        }
    }


    public static void main(String[] args) {

    }

}
